package com.demo.webapp.kcfinder.action;

import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;

import com.demo.webapp.kcfinder.model.DownloadInfo;

/**
 * 默认Action实现
 * @author ryuu.kk
 *
 */
public abstract class ActionSupport implements Action {

	protected Map<String, Object> result;
	private DownloadInfo downloadInfo;
	private InputStream inputStream;
	
	@Override
	public String execute() {
		push("","");
		return SUCCESS;
	}
	
	public Map<String, Object> resultMap() {
		if (result == null) {
			result = new LinkedHashMap<String, Object>();
		}
		return result;
	}
	
	public void push(String key, Object result) {
		this.result.put(key, result);
	}
	
	public void push(InputStream inputStream) {
		this.inputStream = inputStream;
	}
	
	public void push(DownloadInfo downloadInfo) {
		this.downloadInfo = downloadInfo;
	}
	
	@Override
	public void _init() {
		result = new LinkedHashMap<String, Object>();
	}

	@Override
	public void _destory() {
		result = null;
	}

	@Override
	public InputStream getInputStream() {
		return this.inputStream;
	}
	
	@Override
	public DownloadInfo getDownloadInfo() {
		return this.downloadInfo;
	}
}